" javascript

" set filetype for files that should be treated as javascript {{{1
if !empty($ENV_MAC)
  autocmd BufNewFile,BufRead .json setlocal ft=javascript
endif

" Ideal column width is 100 {{{1
autocmd FileType javascript setlocal textwidth=100
autocmd FileType javascript setlocal colorcolumn=100

" Auto clear whitespace {{{1
autocmd BufWritePre *.js ClearWhitespace

autocmd FileType javascript inoreabbre qcons constructor(props) {
  \<cr>super(props);
  \<cr>
  \<cr>this.state = {};
  \<cr>}<esc>
autocmd FileType javascript inoreabbre qbind this.FUNCTION_NAME = this.FUNCTION_NAME.bind(this);<esc>7b*
autocmd FileType javascript inoreabbre qtry try {
  \<cr>} catch (error) {
  \<cr>console.log('Error:', error.message);
  \<cr>}<esc>3ko
